<template>
	<div class="block">
		<div class="title">易书屋后台管理</div>
		<div class="div"><span>用户名：</span><input type="text" v-model="username"/></div>
		<div class="div"><span>密码：</span><input type="password" v-model="password"/></div>
		<div class="div"><span></span><button @click="submit">登录</button></div>
	</div>
</template>
<style>
	html,body{height:100%;}
	body{background:#1666ad}
	.block{width:400px;height:300px;color:#fff;position: absolute;left:50%;top:50%;margin:-150px 0 0 -200px;}
	.block .div{margin-bottom:10px;}
	.block span{display: inline-block;width:80px;font-size:18px;text-align: right;}
	input{width:240px;height:40px;border:none;border-radius: 4px;font-size:16px;padding-left: 10px;box-sizing: border-box;}
	button{width:240px;height:40px;font-size:18px;color:#000;border:none;border-radius: 4px;background: #f2f2f2;}
	.title{text-align: center;font-size: 30px;margin-bottom: 20px;}
</style>
<script>
    module.exports= { 
		data:function(){
			return {   
				username:"",
				password:""
			} 
		},
		methods:{
			submit(){
				ajax({ 
					url:'login/login',
					data:{
						username:this.username,
						password:this.password
					},
					type:'post',
					success(res){
						if(res.state==1){
							location.href='index.html'
						}else{
							window.alert(res.msg)
						}
					} 
				}) 
			} 
		},
		mounted(){
			_this=this;
			document.onkeyup=function(event){
				if(event.keyCode ==13){
					_this.submit();
				}
			}		
		}
	}
	

	
</script>



